package com.example.jpatest3;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@SpringBootApplication
@RestController
public class Jpatest3Application {
    @Autowired
    BookLuoWRRepository
            bookLuoWRRepository;

    @GetMapping("/save_data")
    public void saveData() throws IOException, InterruptedException {
        AddPoem.saveData(bookLuoWRRepository);
    }

    @GetMapping("/find_all_book")
    public Iterable<BookLuoWR>
    find_all_book(Double p1,Double p2){
        return bookLuoWRRepository
                .find2(p1,p2);
    }

    @GetMapping("add_book")
    //http://localhost:8080
    ///add_book?bookName=三国&bookPrice=12.3
    public String addBook
            (BookLuoWR bookZhangZheng){
    //insert into book_zhang_zheng
    // (book_name, book_price) values (?, ?)
        bookLuoWRRepository
                .save(bookZhangZheng);
        return "ok";
    }

    public static void main(String[] args) {
        SpringApplication.run(Jpatest3Application.class, args);

    }

}
